<?php

namespace Home\Model;

class PlayerDataModel extends CommonModel {

    public function createPlayerData($dt){
        $tm = time();
        $dt['create_time'] = $tm;
        $dt['update_time'] = $tm;
        $rs = $this->add($dt);

        if ($rs) {
            $ret['status'] = true;
            $ret['msg'] = '操作成功！';
        } else {
            $ret['status'] = false;
            $ret['msg'] = $this->getError();
        }
        return $ret;
    }

    public function updatePlayerData($get){
        $flt = array(
            'player_id' => $get['player_id'],
            'team_id' => $get['team_id'],
            'match_id' => $get['match_id'],
        );
        if ($get['oper'] == 'plus') {
            $rs = $this->where($flt)->setInc($get['type'], 1);
        } else {
            $rs = $this->where($flt)->setDec($get['type'], 1);
        }

        if ($rs) {
            $ret['status'] = true;
            $ret['msg'] = '操作成功！';
        } else {
            $ret['status'] = false;
            $ret['msg'] = $this->getError();
        }
        return $ret;
    }
}
